package poi;

import java.util.logging.*;

public class GeoInfo {
   
	private static Logger log = Logger.getLogger("POISystem.GeoInfo");
	class GeoPoint  {
		public double latitude;
		public double longitude;
		public GeoPoint()
		{
			latitude=0;
			longitude=0;
		}
		public GeoPoint(double Lat, double Lon)
		{
			latitude = Lat;
			longitude = Lon;
		}
		
	}
	private String locationName;
	private GeoPoint coordinates;
	private LocationType type;
	private int pointID;
	
	public GeoInfo()
	{
		LogFormatter.setLogFormat();
		type=LocationType.UNKNOWN;
		locationName="Unknown";
	}
	public GeoInfo(int _id,String _name,String _type,double _latitude,double _longtitude)
	{
		LogFormatter.setLogFormat();
		pointID = _id;
		coordinates = new GeoPoint(_latitude,_longtitude);
		locationName = new String(_name);
		setLocationTypeName(_type);
	}
	public void setLocationTypeName(String _type)
	{
		if(_type.compareTo("My")==0) type = LocationType.MY; 
		else if(_type.compareTo("Recreation")==0) type = LocationType.RECREATION;
		else if(_type.compareTo("Store")==0) type = LocationType.STORE;
		else if(_type.compareTo("Food")==0) type = LocationType.FOOD;
		else 
		{
			type = LocationType.UNKNOWN;
			log.warning("Unknown type for GeoPoint \""+locationName+"\" used.");
		}
	}
	public double getLatitude()
	{
		return coordinates.latitude;
	}
	public double getLongtitude()
	{
		return coordinates.longitude;
	}
	public LocationType getLocationType()
	{
		return type;		
	}
	public String getLocationName()
	{
		return locationName;
	}	
	public void setLocationName(String S)
	{
		locationName = S;
	}
	public int getPointID()
	{
		return pointID;
	}
	/**
	 * @return the locationName
	 */
	public String getName() {
		return locationName;
	}
	public String getLocationTypeName()
	{
		switch (type) {
		case MY: return "My";
		case RECREATION: return "Recreation";
		case STORE: return "Store";
		case FOOD: return "Food";
		default:
			break;
		}		
		return "Unknown";

	}
	public static String locationTypeNameToString(LocationType lt) {
		switch (lt) {
		case MY: return "My";
		case RECREATION: return "Recreation";
		case STORE: return "Store";
		case FOOD: return "Food";
		default:
			break;
		}		
		return "Unknown";

	}
	
	public String toString() {
		String res = new String();
		res = "" + pointID + ",";
		res += locationName + ",";
		res += getLocationTypeName() + ",";
		res += coordinates.latitude + "," + coordinates.longitude;
		return res;
	}
}

